package org.hawk.gwtppc.webtest.tests.classsuite;

import java.lang.reflect.Modifier;
import java.util.Arrays;

import org.hawk.gwtppc.webtest.common.Asserts;
import org.hawk.gwtppc.webtest.common.Test;
import org.hawk.gwtppc.webtest.tests.mock.SubClassMock1;

public class GetMethodsTest implements Test {

	public void run() throws Throwable {
		Asserts.assertEquals(SubClassMock1.class.getMethods().length, 9, "Expected array of length 9 but got " +
				SubClassMock1.class.getMethods().length + ": " + Arrays.toString(SubClassMock1.class.getMethods()));
		
		Asserts.assertEquals(SubClassMock1.class.getMethods()[6].toString(), "public java.lang.String org.hawk.gwtppc.webtest.tests.mock.SubClassMock1.getValue()");
		Asserts.assertEquals(SubClassMock1.class.getMethods()[6].getModifiers(), Modifier.PUBLIC);
		Asserts.assertEquals(SubClassMock1.class.getMethods()[6].getReturnType(), String.class);
		Asserts.assertEquals(SubClassMock1.class.getMethods()[6].getParameterTypes().length, 0);
		
		Asserts.assertEquals(SubClassMock1.class.getMethods()[1].toString(), "public java.lang.Appendable org.hawk.gwtppc.webtest.tests.mock.ClassMock.append(java.lang.CharSequence)");
		Asserts.assertEquals(SubClassMock1.class.getMethods()[1].getModifiers(), Modifier.PUBLIC);
		Asserts.assertEquals(SubClassMock1.class.getMethods()[1].getReturnType(), Appendable.class);
		Asserts.assertEquals(SubClassMock1.class.getMethods()[1].getParameterTypes().length, 1);
		Asserts.assertEquals(SubClassMock1.class.getMethods()[1].getParameterTypes()[0], CharSequence.class);
		
		Asserts.assertEquals(SubClassMock1.class.getMethods()[2].toString(), "public java.lang.Appendable org.hawk.gwtppc.webtest.tests.mock.ClassMock.append(java.lang.CharSequence,int,int)");
		Asserts.assertEquals(SubClassMock1.class.getMethods()[2].getModifiers(), Modifier.PUBLIC);
		Asserts.assertEquals(SubClassMock1.class.getMethods()[2].getReturnType(), Appendable.class);
		Asserts.assertEquals(SubClassMock1.class.getMethods()[2].getParameterTypes().length, 3);
		Asserts.assertEquals(SubClassMock1.class.getMethods()[2].getParameterTypes()[0], CharSequence.class);
		Asserts.assertEquals(SubClassMock1.class.getMethods()[2].getParameterTypes()[1], int.class);
		Asserts.assertEquals(SubClassMock1.class.getMethods()[2].getParameterTypes()[2], int.class);
		
		Asserts.assertEquals(SubClassMock1.class.getMethods()[0].toString(), "public java.lang.Appendable org.hawk.gwtppc.webtest.tests.mock.ClassMock.append(char)");
		Asserts.assertEquals(SubClassMock1.class.getMethods()[4].toString(), "public org.hawk.gwtppc.webtest.tests.mock.ClassMock org.hawk.gwtppc.webtest.tests.mock.ClassMock.getAppendable()");
		Asserts.assertEquals(SubClassMock1.class.getMethods()[3].toString(), "public boolean java.lang.Object.equals(java.lang.Object)");
		Asserts.assertEquals(SubClassMock1.class.getMethods()[8].toString(), "public java.lang.String java.lang.Object.toString()");
		Asserts.assertEquals(SubClassMock1.class.getMethods()[7].toString(), "public native int java.lang.Object.hashCode()");
		Asserts.assertEquals(SubClassMock1.class.getMethods()[5].toString(), "public final native java.lang.Class java.lang.Object.getClass()");
	}

	public String getName() {
		return "getMethods()";
	}

}
